<?php
/**
 * @copyright keke-teach
 * @author shang
 * @version v 1.2
 * 2010-9-2 10:42:00
 */
if (! defined ( 'IN_KEKE' )) {
	exit ( 'Access Denied' );
}

$shop_info = $shop_info_arr[0];

$order_obj = new Keke_witkey_service_order_class();

$service_status=keke_glob_class::get_service_status();

$sale_count=db_factory::query(" select count(*) as count,order_status as status from ".TABLEPRE."witkey_service_order where sale_uid = '$uid' group by order_status");
foreach ($sale_count as $k=>$v) {
	$temp_arr[$v['status']] = $v['count'];
}
$sale_count = $temp_arr;
$where = '  1 = 1 and a.sale_uid = '.$uid;

$order_obj->setWhere(" sale_uid = $uid ");
$count_all = $order_obj->count_keke_witkey_service_order();
if($by){
	$where .= " and a.order_status=$by";
}


$page_size = intval($page_size)?intval($page_size):10;
	

$sql_str = "select  a.*,b.title,b.price from
					".TABLEPRE."witkey_service_order as a 
					left join ".TABLEPRE."witkey_service as b on a.service_id= b.service_id
					where ";
$sql_count = "select  count(*) as count from
					".TABLEPRE."witkey_service_order a
					left join ".TABLEPRE."witkey_service b on a.service_id= b.service_id
					where ";
$ct = db_factory::query($sql_count.$where);
$count = $ct[0][count];


$url ='index.php?do='.$do.'&view='.$view.'&by= '.$by;
$page = $_GET ['page'] ? $_GET ['page'] : 1;
$limit=$page_size;
$pages = $page_obj->getPages($count,$limit,$page,$url);

$order_arr = db_factory::query($sql_str.$where.$pages[where]);
require_once keke_tpl_class::template ($do."_".$view);